#ifndef __HOUGHTRANSFORM_H__
#define __HOUGHTRANSFORM_H__

#include "ui_houghTransform.h"
#include "imagemodel.h"
#include <QDialog>
#include <QList>

class SLine{
public:
        SLine(float k,float b);
        SLine(float k,float b,int Xl,int Yl,int Xr,int Yr);
        inline float getK();
        inline int getB();
        void setZeroPoint(int x0,int y0);
        inline int getGlobalB(int x0,int y0);
        int getGlobalB1();
        float k;
        float b;
        inline int getGlobalXl(){return(Xl+X0);}
        inline int getGlobalYl(){return(Yl+Y0);}
        inline int getGlobalXr(){return(Xr+X0);}
        inline int getGlobalYr(){return(Yr+Y0);}
private:
        int Xl;
        int Xr;
        int Yl;
        int Yr;
        int X0;
        int Y0;
};

class HoughTransform{
public:
        HoughTransform(int height,int width,int cellSize);
        void addPoint(QPoint point);
        void addPoint(int x,int y);
        void drawLines(int count);
        QList<SLine> getLineList(int count,int x0,int y0);
        QImage sourceImage;
        QImage houghSpace;
        unsigned int maxVal;
        int cellSize;
        int half;
private:
        int pointCount;
        int height;
        int width;
};

class dlgHoughTransform:public QDialog,Ui::dlgHoughTransform{
        Q_OBJECT
public:
        QImage ScaleImageBright(const QImage& img);
        dlgHoughTransform(QWidget* parent = NULL);
private:
        ImageModel imModel;
        ImageTabel *imView;
        QImage scale;
        int minX;
        int maxX;
        HoughTransform ht;
private slots:
        void on_pushButton_clicked();
        void on_lbSourceImage_customContextMenuRequested(QPoint);
};

#endif // __HOUGHTRANSFORM_H__

